package com.pinc.exam;

public class Question_Class extends Base_Class implements Comparable<Question_Class> {
	public String question;
	public int position;
	public int corr;
	public int total;
	public float point;
	public static int orderby = 0;

	public Question_Class(long id, int position, String question, int corr, int total, float point) {
		super(id);
		this.position = position;
		this.question = question;
		this.corr = corr;
		this.total = total;
		this.point = point;
	}

	@Override
	public int compareTo(Question_Class another) {
		do
		{
			if ( orderby == 1)
			{
				if ( total == 0 && another.total == 0)
					break;
				else
				{
					if ( total == 0)
						return 1;
					else if (another.total == 0)
						return -1;
					else
					{
						if ( (float)corr/(float)total < (float)another.corr/(float)another.total)
							return -1;
						else if ( (float)corr/(float)total > (float)another.corr/(float)another.total )
							return 1;
						else
							return 0;
					}
				}
			}
		}while(false);

		if ( position < another.position)
			return -1;
		else if ( position > another.position)
			return 1;
		else
			return 0;
	}
}
